package com.example.demo.security;

import com.example.demo.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hasee
 * on 2019/11/19 13:23
 */
@Service
public class MyUserDetailsService implements UserDetailsService {

    @Autowired
    private UserDao userDao;

    @Override
    public UserDetails loadUserByUsername(String userAccount) throws UsernameNotFoundException {
        if(userDao.findUserBasicInfo(userAccount) == null){
            throw new UsernameNotFoundException(userAccount);
        }
        return new MyUserPrincipal();
    }
}
